package com.google.code.twiddling.core.chain;

import com.google.code.twiddling.core.chain.Processor;
import com.google.code.twiddling.core.command.CommandContext;
import com.google.code.twiddling.core.command.ICommand;
import com.google.code.twiddling.core.util.StringUtil;

import java.util.List;
import java.util.ArrayList;

/**
 * Executor to process command
 *
 * @author <a href="mailto:yy.young@gmail.com">Young Yang</a>
 * @create Dec 12, 2008 10:33:07 AM
 */
public class CommandProcessor extends Processor {

    //TODO: commands provided by OS
    private List<String> osCommands = new ArrayList<String>();

    {
        osCommands.add("ls");
        osCommands.add("grep");
        osCommands.add("find");
    }

    protected void process(CommandContext commandContext) throws Exception {
        // get command instance from commandContext directly
        ICommand command = commandContext.getCommand();        
        command.execute(commandContext);
    }

}
